//企业简介富文本编辑栏验证
function validateContent(){
    	var c = $($('.note-editable')[0]).html().toString();
    	if("" == c.trim() || "<p><br></p>" == c.trim()){
    		$($('.note-editor')[0]).removeClass("content-control has-success").addClass("content-control error");
        	if($('#content-label').hasClass("content-success")){
        		$('#content-label').removeClass("content-success");
        	}
        	$("#contents-error").html('内容不能为空'); 
        	$("#contents-error").css('display','inline'); 
        	return false;
        }else{
        	$($('.note-editor')[0]).removeClass("content-control error").addClass("content-control has-success");
        	$('#content-label').addClass("content-success");
        	$("#contents-error").css('display','none'); 
        	return true;
        }
    };
    //核心成员简介富文本编辑栏验证
    var validateContent1 = function(){
    	var c = $($('.note-editable')[1]).html().toString();
    	if("" == c.trim() || "<p><br></p>" == c.trim()){
        	$($('.note-editor')[1]).removeClass("content-control has-success").addClass("content-control error");
        	if($('#content-label1').hasClass("content-success")){
        		$('#content-label1').removeClass("content-success");
        	}
        	$("#contents-error1").html('内容不能为空'); 
        	$("#contents-error1").css('display','inline'); 
        	return false;
        }else{
        	$($('.note-editor')[1]).removeClass("content-control error").addClass("content-control has-success");
        	$('#content-label1').addClass("content-success");
        	$("#contents-error1").css('display','none'); 
        	return true;
        }
    };
    //商业模式富文本编辑框验证
    var validateContent2 = function(){
    	for(var i=2;i<8;i++){
    		var c = $($('.note-editable')[i]).html().toString();
        	if("" == c.trim() || "<p><br></p>" == c.trim()){
            	$($('.note-editor')[i]).removeClass("content-control has-success").addClass("content-control error");
            	if($('#content-label'+i).hasClass("content-success")){
            		$('#content-label'+i).removeClass("content-success");
            	}
            	$("#contents-error"+i).html('内容不能为空'); 
            	$("#contents-error"+i).css('display','inline'); 
            	return false;
            }else{
            	$($('.note-editor')[i]).removeClass("content-control error").addClass("content-control has-success");
            	$('#content-label'+i).addClass("content-success");
            	$("#contents-error"+i).css('display','none'); 
            }
    	}
    	return true;
    };
    
    //财务数据富文本编辑框验证
    var validateContent8 = function(){
    	var c = $($('.note-editable')[8]).html().toString();
    	if("" == c.trim() || "<p><br></p>" == c.trim()){
        	$($('.note-editor')[8]).removeClass("content-control has-success").addClass("content-control error");
        	if($('#content-label8').hasClass("content-success")){
        		$('#content-label8').removeClass("content-success");
        	}
        	$("#contents-error8").html('内容不能为空'); 
        	$("#contents-error8").css('display','inline'); 
        	return false;
        }else{
        	$($('.note-editor')[8]).removeClass("content-control error").addClass("content-control has-success");
        	$('#content-label8').addClass("content-success");
        	$("#contents-error8").css('display','none'); 
        	return true;
        }
    };
    var validateContent9 = function(){
    	var c = $($('.note-editable')[9]).html().toString();
    	if("" == c.trim() || "<p><br></p>" == c.trim()){
        	$($('.note-editor')[9]).removeClass("content-control has-success").addClass("content-control error");
        	if($('#content-label9').hasClass("content-success")){
        		$('#content-label9').removeClass("content-success");
        	}
        	$("#contents-error9").html('内容不能为空'); 
        	$("#contents-error9").css('display','inline'); 
        	return false;
        }else{
        	$($('.note-editor')[9]).removeClass("content-control error").addClass("content-control has-success");
        	$('#content-label9').addClass("content-success");
        	$("#contents-error9").css('display','none'); 
        	return true;
        }
    };
    
//初始化富文本编辑框 
function initSummernote(){
	$($('.summernote')[0]).summernote({
    	height: 260, 
    	toolbar: [  
    	          ['style', ['style']],
    	          ['style', ['bold', 'italic', 'underline', 'clear']],  
    	          ['fontsize', ['fontsize']],  
    	          ['fontname',['fontname']],
    	          ['color', ['color']],  
    	          ['para', ['ul', 'ol', 'paragraph']],  
    	          ['height', ['height']],  
    	          ['table',['table']],
    	          ['insert', ['picture','link']] ,
    	          ['help',['help']]
    	        ], 
    	onImageUpload: function(files, editor, $editable) {
             sendFile(files,editor,$editable);
            },
        onblur: function(e) {
        	validateContent(0);
        },
        onfocus:function(e){
        	validateContent(0);
        },
        onChange: function(contents, $editable) {
        	validateContent(0);
        },
        bFullscreen:false,
    });
    
    $($('.summernote')[1]).summernote({
    	height: 210, 
    	toolbar: [  
    	          ['style', ['style']],
    	          ['style', ['bold', 'italic', 'underline', 'clear']],  
    	          ['fontsize', ['fontsize']],  
    	          ['fontname',['fontname']],
    	          ['color', ['color']],  
    	          ['para', ['ul', 'ol', 'paragraph']],  
    	          ['height', ['height']],  
    	          ['table',['table']],
    	          ['insert', ['picture','link']] ,
    	          ['help',['help']]
    	        ], 
    	onImageUpload: function(files, editor, $editable) {
             sendFile(files,editor,$editable);
            },
        onblur: function(e) {
        	validateContent1();
        },
        onfocus:function(e){
        	validateContent1();
        },
        onChange: function(contents, $editable) {
        	validateContent1();
        },
        bFullscreen:false,
    });
    
    $($('.summernote')[2]).summernote({
    	height: 230, 
    	toolbar: [  
    	          ['style', ['style']],
    	          ['style', ['bold', 'italic', 'underline', 'clear']],  
    	          ['fontsize', ['fontsize']],  
    	          ['fontname',['fontname']],
    	          ['color', ['color']],  
    	          ['para', ['ul', 'ol', 'paragraph']],  
    	          ['height', ['height']],  
    	          ['table',['table']],
    	          ['insert', ['picture','link']] ,
    	          ['help',['help']]
    	        ], 
    	onImageUpload: function(files, editor, $editable) {
             sendFile(files,editor,$editable);
            },
        onblur: function(e) {
        	validateContent2();
        },
        onfocus:function(e){
        	validateContent2();
        },
        onChange: function(contents, $editable) {
        	validateContent2();
        },
        bFullscreen:false,
    });
    $($('.summernote')[3]).summernote({
    	height: 230, 
    	toolbar: [  
    	          ['style', ['style']],
    	          ['style', ['bold', 'italic', 'underline', 'clear']],  
    	          ['fontsize', ['fontsize']],  
    	          ['fontname',['fontname']],
    	          ['color', ['color']],  
    	          ['para', ['ul', 'ol', 'paragraph']],  
    	          ['height', ['height']],  
    	          ['table',['table']],
    	          ['insert', ['picture','link']] ,
    	          ['help',['help']]
    	        ], 
    	onImageUpload: function(files, editor, $editable) {
             sendFile(files,editor,$editable);
            },
        onblur: function(e) {
        	validateContent2();
        },
        onfocus:function(e){
        	validateContent2();
        },
        onChange: function(contents, $editable) {
        	validateContent2();
        },
        bFullscreen:false,
    });
    $($('.summernote')[4]).summernote({
    	height: 230, 
    	toolbar: [  
    	          ['style', ['style']],
    	          ['style', ['bold', 'italic', 'underline', 'clear']],  
    	          ['fontsize', ['fontsize']],  
    	          ['fontname',['fontname']],
    	          ['color', ['color']],  
    	          ['para', ['ul', 'ol', 'paragraph']],  
    	          ['height', ['height']],  
    	          ['table',['table']],
    	          ['insert', ['picture','link']] ,
    	          ['help',['help']]
    	        ], 
    	onImageUpload: function(files, editor, $editable) {
             sendFile(files,editor,$editable);
            },
        onblur: function(e) {
        	validateContent2();
        },
        onfocus:function(e){
        	validateContent2();
        },
        onChange: function(contents, $editable) {
        	validateContent2();
        },
        bFullscreen:false,
    });
    $($('.summernote')[5]).summernote({
    	height: 230, 
    	toolbar: [  
    	          ['style', ['style']],
    	          ['style', ['bold', 'italic', 'underline', 'clear']],  
    	          ['fontsize', ['fontsize']],  
    	          ['fontname',['fontname']],
    	          ['color', ['color']],  
    	          ['para', ['ul', 'ol', 'paragraph']],  
    	          ['height', ['height']],  
    	          ['table',['table']],
    	          ['insert', ['picture','link']] ,
    	          ['help',['help']]
    	        ], 
    	onImageUpload: function(files, editor, $editable) {
             sendFile(files,editor,$editable);
            },
        onblur: function(e) {
        	validateContent2();
        },
        onfocus:function(e){
        	validateContent2();
        },
        onChange: function(contents, $editable) {
        	validateContent2();
        },
        bFullscreen:false,
    });
    $($('.summernote')[6]).summernote({
    	height: 230, 
    	toolbar: [  
    	          ['style', ['style']],
    	          ['style', ['bold', 'italic', 'underline', 'clear']],  
    	          ['fontsize', ['fontsize']],  
    	          ['fontname',['fontname']],
    	          ['color', ['color']],  
    	          ['para', ['ul', 'ol', 'paragraph']],  
    	          ['height', ['height']],  
    	          ['table',['table']],
    	          ['insert', ['picture','link']] ,
    	          ['help',['help']]
    	        ], 
    	onImageUpload: function(files, editor, $editable) {
             sendFile(files,editor,$editable);
            },
        onblur: function(e) {
        	validateContent2();
        },
        onfocus:function(e){
        	validateContent2();
        },
        onChange: function(contents, $editable) {
        	validateContent2();
        },
        bFullscreen:false,
    });
    $($('.summernote')[7]).summernote({
    	height: 230, 
    	toolbar: [  
    	          ['style', ['style']],
    	          ['style', ['bold', 'italic', 'underline', 'clear']],  
    	          ['fontsize', ['fontsize']],  
    	          ['fontname',['fontname']],
    	          ['color', ['color']],  
    	          ['para', ['ul', 'ol', 'paragraph']],  
    	          ['height', ['height']],  
    	          ['table',['table']],
    	          ['insert', ['picture','link']] ,
    	          ['help',['help']]
    	        ], 
    	onImageUpload: function(files, editor, $editable) {
             sendFile(files,editor,$editable);
            },
        onblur: function(e) {
        	validateContent2();
        },
        onfocus:function(e){
        	validateContent2();
        },
        onChange: function(contents, $editable) {
        	validateContent2();
        },
        bFullscreen:false,
    });
    
    $($('.summernote')[8]).summernote({
    	height: 230, 
    	toolbar: [  
    	          ['style', ['style']],
    	          ['style', ['bold', 'italic', 'underline', 'clear']],  
    	          ['fontsize', ['fontsize']],  
    	          ['fontname',['fontname']],
    	          ['color', ['color']],  
    	          ['para', ['ul', 'ol', 'paragraph']],  
    	          ['height', ['height']],  
    	          ['table',['table']],
    	          ['insert', ['picture','link']] ,
    	          ['help',['help']]
    	        ], 
    	onImageUpload: function(files, editor, $editable) {
             sendFile(files,editor,$editable);
            },
        onblur: function(e) {
        	validateContent8();
        },
        onfocus:function(e){
        	validateContent8();
        },
        onChange: function(contents, $editable) {
        	validateContent8();
        },
        bFullscreen:false,
    });
    $($('.summernote')[9]).summernote({
    	height: 230, 
    	toolbar: [  
    	          ['style', ['style']],
    	          ['style', ['bold', 'italic', 'underline', 'clear']],  
    	          ['fontsize', ['fontsize']],  
    	          ['fontname',['fontname']],
    	          ['color', ['color']],  
    	          ['para', ['ul', 'ol', 'paragraph']],  
    	          ['height', ['height']],  
    	          ['table',['table']],
    	          ['insert', ['picture','link']] ,
    	          ['help',['help']]
    	        ], 
    	onImageUpload: function(files, editor, $editable) {
             sendFile(files,editor,$editable);
            },
        onblur: function(e) {
        	validateContent9();
        },
        onfocus:function(e){
        	validateContent9();
        },
        onChange: function(contents, $editable) {
        	validateContent9();
        },
        bFullscreen:false,
    });
    
    //编辑栏上传图片文件
    function sendFile(file, editor, $editable) {
    	for(var i = 0;i < file.length;i++){
    		data = new FormData();
            data.append("file", file[i]);
            url = ctx+"/project/imgUploads";
            $.ajax({
                data: data,
                type: "POST",
                url: url,
                cache: false,
                contentType: false,
                processData: false,
                success: function (msg) {
                	if(1 == msg.code){
                		editor.insertImage($editable, imagePrefix+msg.data);
                	}
                	else{
                		bootbox.alert(msg.message);
                	}
                }
         	});
    	}
        
		};
}
    